import React, { Component } from "react";
class Moxing extends Component {
  componentDidMount() {
    this.dsq = setInterval(function () {
      console.log(1);
    }, 100);
  }
  componentWillUnmount() {
    console.log("组件卸载了");
    clearInterval(this.dsq);
  }
  render() {
    return <h1>昊辰</h1>;
  }
}
export default class App extends Component {
  state = {
    tianshi: true,
  };
  dianji = () => {
    this.setState({
      tianshi: false,
    });
  };
  render() {
    return (
      <div>
        {this.state.tianshi ? <Moxing></Moxing> : ""}
        <button onClick={this.dianji}>点击</button>
      </div>
    );
  }
}
